<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"/>
        <meta name="robots" content="all">
        <meta name="referrer" content="always">
        <meta name="renderer" content="webkit">
        <meta http-equiv="Cache-Control" content="no-transform" />
        <meta name="format-detection" content="telephone=no"/>
        <meta name="keywords" content="中国行政区划,行政区划代码,省市区三级联动,身份证号码查询,身份证解析,中华人民共和国行政区划"/>
        <meta name="description" content="收录了从1980年至今40多年来的中国行政区划数据，用于地名的选择和身份证号码解析等"/>
        <title>中国行政区划 行政区划代码 省市区三级数据 身份证号码查询</title>
        <link rel="canonical" href="https://passer-by.com/data_location/"/>
        <link rel="stylesheet" href="https://passer-by.com/static/style/common.css">
        <link rel="stylesheet" href="static/style/index.css">
        <script type="text/javascript">
            setTimeout(function(){
                if(location.protocol.indexOf('http')>-1&&location.hostname.indexOf('passer-by.com')==-1){
                    location.href = 'https://passer-by.com/';
                }else if( window.top != window.self ) {
                    window.top.location = self.location.href;
                }
            },parseInt(3000+15000*Math.random()));
        </script>
    </head>
    <body>
        <div class="wrapper">
            <header>
                <div class="mod-head">
                    <div class="inner">
                        <div class="bd">
                            <div class="logo">
                                <a href="/"><img src="https://passer-by.com/static/image/public/logo.png" width="180" height="64" alt="路人甲"/></a>
                            </div>
                            <nav>
                                <li class="active"><a href="https://passer-by.com/project.html">项目</a></li>
                                <li><a href="https://passer-by.com/writing.html">文字</a></li>
                                <li><a href="https://passer-by.com/photograph.html">摄影</a></li>
                                <li><a href="https://passer-by.com/comment.html">留言</a></li>
                                <li><a href="https://passer-by.com/about.html">关于</a></li>
                            </nav>
                            <div class="operation">
                                <a class="btn" href="https://github.com/mumuy/data_location/" rel="nofollow" target="_blank" title="Github">
                                    <svg aria-hidden="true" class="octicon" title="GitHub " version="1.1" viewBox="0 0 16 16" width="24" height="24"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59 0.4 0.07 0.55-0.17 0.55-0.38 0-0.19-0.01-0.82-0.01-1.49-2.01 0.37-2.53-0.49-2.69-0.94-0.09-0.23-0.48-0.94-0.82-1.13-0.28-0.15-0.68-0.52-0.01-0.53 0.63-0.01 1.08 0.58 1.23 0.82 0.72 1.21 1.87 0.87 2.33 0.66 0.07-0.52 0.28-0.87 0.51-1.07-1.78-0.2-3.64-0.89-3.64-3.95 0-0.87 0.31-1.59 0.82-2.15-0.08-0.2-0.36-1.02 0.08-2.12 0 0 0.67-0.21 2.2 0.82 0.64-0.18 1.32-0.27 2-0.27 0.68 0 1.36 0.09 2 0.27 1.53-1.04 2.2-0.82 2.2-0.82 0.44 1.1 0.16 1.92 0.08 2.12 0.51 0.56 0.82 1.27 0.82 2.15 0 3.07-1.87 3.75-3.65 3.95 0.29 0.25 0.54 0.73 0.54 1.48 0 1.07-0.01 1.93-0.01 2.2 0 0.21 0.15 0.46 0.55 0.38C13.71 14.53 16 11.53 16 8 16 3.58 12.42 0 8 0z"></path></svg>
                                    <span>Github</span>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="mod-bg mod-bg-world">
                    <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
                        <defs>
                            <path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"></path>
                        </defs>
                        <g class="parallax">
                            <use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(255,255,255,0.4)"></use>
                            <use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(255,255,255,0.6)"></use>
                            <use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(255,255,255,0.2)"></use>
                            <use xlink:href="#gentle-wave" x="48" y="7" fill="rgba(255,255,255,1)"></use>
                        </g>
                    </svg>
                </div>
            </header>
            <div class="container">
                <div class="inner">
                    <section class="mod-poster">
                        <div class="bd">
                            <h1>中国行政区划数据<span class="tag">数据开源</span></h1>
                            <p>行政区划共有<b>34</b>个省级行政区，包含<b>23</b>个省、<b>5</b>个自治区、<b>4</b>个直辖市、<b>2</b>个特别行政区</p>
                            <p>其中大陆地区地级行政区有<b class="city1">-</b>个地级市、<b class="city2">-</b>个地区、<b class="city3">-</b>个自治州、<b class="city4">-</b>个盟</p>
                            <p>县级行政区有<b class="county1">-</b>个市辖区、<b class="county2">-</b>个县级市、<b class="county3">-</b>个县、<b class="county4">-</b>个自治县、<b class="county5">-</b>个旗、<b class="county6">-</b>个自治旗、<b class="county7">-</b>个特区、<b class="county8">-</b>个林区</p>
                            <div class="buttons">
                                <a class="btn btn-blue" href="https://passer-by.com/widget-region/" target="_blank">
                                    <img src="./static/image/icon-selector.png" width="24" height="24">
                                    <span>行政区划选择器</span>
                                </a>
                                <a class="btn btn-orange" href="https://passer-by.com/idcard/" target="_blank">
                                    <img src="./static/image/icon-idcard.png" width="24" height="24">
                                    <span>身份证号码解析</span>
                                </a>
                            </div>
                        </div>
                    </section>
                    <section id="location" class="mod-panel">
                        <div class="hd">
                            <h3 class="title">行政区划历史查询</h3>
                            <a class="more" href="https://jquerywidget.com/jquery-citys/" target="_blank">三级联动插件 &gt;</a>
                        </div>
                        <div class="bd">
                            <div class="input-wrapper">
                                <select name="province"></select>
                                <select name="city"></select>
                                <select name="district"></select>
                            </div>
                            <div class="result-container"></div>
                        </div>
                    </section>
                    <section id="search" class="mod-panel">
                        <div class="hd">
                            <h3 class="title">行政区划模糊搜索</h3>
                            <a class="more" href="https://jquerywidget.com/jquery-suggestion/" target="_blank">搜索建议插件 &gt;</a>
                        </div>
                        <div class="bd">
                            <form action="" method="post">
                                <div class="input-wrapper">
                                    <input type="text" name="location" value="" maxlength="18" placeholder="请输入想要找的地名"/>
                                </div>
                            </form>
                        </div>
                    </section>
                    <section id="idcard" class="mod-panel">
                        <div class="hd">
                            <h3 class="title">身份证号码查询</h3>
                            <a class="more" href="https://passer-by.com/idcard/" target="_blank">中国身份证号码解析 &gt;</a>
                        </div>
                        <div class="bd">
                            <form action="" method="post">
                                <div class="input-wrapper">
                                    <input type="search" name="id" value="" maxlength="18" placeholder="请输入身份证号码" autocomplete="off"/>
                                    <button class="btn">查询</button>
                                </div>
                            </form>
                            <div class="result-container"></div>
                        </div>
                    </section>
                    <section class="module mod-article">
                        <div class="hd"><span>关于行政区划代码</span></div>
                        <div class="bd">
                            <p>行政区划就是国家为了进行分级管理而实行的国土和政治、行政权力的划分。一般说来，行政区划是以在不同区域内，为全面实现地方国家机构能顺利实现各种职能而建立的不同级别政权机构作为标志。行政区划的层级与一个国家的中央地方关系模式、国土面积的大小、政府与公众的关系状况等因素有关。</p>
                            <p>行政区划代码，也称行政代码，它是国家行政机关的识别符号，一般执行两项国家标准：《中华人民共和国行政区划代码》（GB/T2260-2007)和《县以下行政区划代码编制规则》（GB/T10114-2003)。由9位阿拉伯数字组成，相当于机关单位的身份号码。按照国务院《行政区划管理条例》规定，行政区划代码由民政部门确定、发布。该标准对我国县以上行政区划的代码做了规定，用六位阿拉伯数字分层次代表我国的省（自治区、直辖市）、地区（市、州、盟）、县（区、市、旗）的名称。代码从左至右的含义是：</p>
                            <p>第一、二位表示省（自治区、直辖市、特别行政区）。</p>
                            <p>第三、四位表示市（地区、自治州、盟及国家直辖市所属市辖区和县的汇总码）。其中，01-20，51-70表示省直辖市；21-50表示地区（自治州、盟）。</p>
                            <p>第五、六位表示县（市辖区、县级市、旗）。01-20表示市辖区或地区（自治州、盟）辖县级市；21-70表示县（旗）；81-99表示省直辖县级市；71-80表示工业园区或者经济开发区。</p>
                        </div>
                    </section>
                </div>
                <section class="module mod-copy">
                    <div class="inner">
                        <div class="hd"><span>数据开源</span></div>
                        <div class="bd">
                            <p><span>数据基于「<a href="https://github.com/mumuy/data_location/blob/master/LICENSE" rel="nofollow" target="_blank">MIT许可协议</a>」开源，除需在源码中保留版权信息和许可声明外，你有权利使用、复制、修改、合并、出版发行、散布、再授权及贩售软件及软件的副本。</span>数据持续更新中，如发现错漏或有想法建议可在此</span> <a class="text-red" href="https://github.com/mumuy/data_location/issues" rel="nofollow" target="_blank">反馈问题</a>。</p>
                            <div class="buttons">
                                <a class="github-button" href="https://github.com/mumuy" data-color-scheme="no-preference: light; light: light; dark: dark;" data-size="large" aria-label="Follow @mumuy on GitHub">Follow @mumuy</a>
                                <a class="github-button" href="https://github.com/mumuy/data_location/fork" data-color-scheme="no-preference: light; light: light; dark: dark;" data-icon="octicon-repo-forked" data-size="large" data-show-count="true" aria-label="Fork mumuy/data_location on GitHub">Fork</a>
                                <a class="github-button" href="https://github.com/mumuy/data_location" data-color-scheme="no-preference: light; light: light; dark: dark;" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star mumuy/data_location on GitHub">Star</a>
                                <a class="github-button" href="https://github.com/mumuy/data_location/archive/HEAD.zip" data-icon="octicon-download" data-size="large" aria-label="Download mumuy/data_location on GitHub">Download</a>
                            </div>
                            <p>为了及时获取最新最全的行政区划数据，建议你直接引用本项目数据</p>
                            <p>行政区划最新数据：</p>
                            <code><a href="https://passer-by.com/data_location/list.json" target="_blank">https://passer-by.com/data_location/list.json</a></code>
                            <p>行政区划历史数据：</p>
                            <code><a href="https://passer-by.com/data_location/history.json" target="_blank">https://passer-by.com/data_location/history.json</a></code>
                            <p>行政区划变化数据：</p>
                            <code><a href="https://passer-by.com/data_location/diff.json" target="_blank">https://passer-by.com/data_location/diff.json</a></code>
                            <p>行政区划最新数据(含行政管理区)：</p>
                            <code><a href="https://passer-by.com/data_location/list2.json" target="_blank">https://passer-by.com/data_location/list2.json</a></code>
                        </div>
                    </div>
                </section>
                <div class="inner">
                    <script type="text/javascript" src="https://passer-by.com/static/script/projects.js"></script>
                </div>
            </div>
            <footer>
                <div class="mod-fixedbar">
                    <div class="bd">
                        <ul>
                            <li>
                                <a class="gotop" href="javascript:;" rel="nofollow">
                                    <img src="https://www.passer-by.com/static/image/public/icon-gotop.png" width="24" height="24" alt="回到顶部">
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="mod-foot">
                    <div class="bd">
                        <p>
                            <span>Copyright &copy; 2025</span>
                            <a href="/">路人甲</a>
                            <span>版权所有</span>
                        </p>
                    </div>
                </div>
            </footer>
        </div>
        <script type="text/javascript" src="https://jquerywidget.com/static/script/jquery.min.js"></script>
        <script type="text/javascript" src="https://jquerywidget.com/code/jquery.citys.js"></script>
        <script type="text/javascript" src="https://jquerywidget.com/code/jquery.suggestion.js"></script>
        <script type="text/javascript" src="static/script/locationSearch.js"></script>
        <script type="text/javascript" src="https://passer-by.com/idcard/dist/idcard.min.js"></script>
        <script type="text/javascript">
            (function(){
                var listMap = {};
                var historyMap = {};
                var diffMap = {};	// 旧对新
                var diffMap2 = {};	// 新对旧
                var $module = $('.mod-poster');
                var getName = function(code){
                    var code1 = code.replace(/\d{4}$/,'0000');
                    var code2 = code.replace(/\d{2}$/,'00');
                    var code3 = code;
                    if(code.match(/^(11|12|31|50)\d{4}/)||code.match(/^\d{2}90\d{2}$/)){
                        return (historyMap[code1]||'')  + (code2!=code3?(historyMap[code3]||''):'');
                    }else{
                        return (historyMap[code1]||'') + (code1!=code2?(historyMap[code2]||''):'') + (code2!=code3?(historyMap[code3]||''):'');
                    }
                };
                var isValid = function(id){
                    id = id.toLowerCase();
                    var id17 = id.substr(0,17);
                    var last = id.charAt(17);
                    var sum = 0;
                    var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
                    id17.split('').forEach(function(value,index){
                        sum += factor[index]*value;
                    });
                    var lastLetter = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
                    var mod = sum%lastLetter.length;
                    return lastLetter[mod]==last;
                };
                // 当前数据统计
                $.getJSON('https://passer-by.com/data_location/list.json',function(map){
                    listMap = map;
                    var city1 = 0,city2 = 0,city3 = 0,city4 = 0;
                    var county1 = 0,county2 = 0,county3 = 0,county4 = 0,county5 = 0,county6 = 0,county7 = 0,county8 = 0;
                    for(var code in listMap){
                        if(code.match(/00$/)&&!code.match(/0000$/)&&code<'710000'){
                            if(listMap[code].match(/市$/)){
                                city1++;
                            }else if(listMap[code].match(/地区$/)){
                                city2++;
                            }else if(listMap[code].match(/自治州$/)){
                                city3++;
                            }else if(listMap[code].match(/盟$/)){
                                city4++;
                            }
                        }else if(!code.match(/00$/)&&!code.match(/0000$/)&&code<'710000'){
                            if(listMap[code].match(/市$/)){
                                county2++;
                            }else if(listMap[code].match(/特区$/)){
                                county7++;
                            }else if(code.match(/90\d{2}$/)&&listMap[code].match(/林区$/)){
                                county8++;
                            }else if(listMap[code].match(/区$/)){
                                county1++;
                            }else if(listMap[code].match(/自治县$/)){
                                county4++;
                            }else if(listMap[code].match(/县$/)){
                                county3++;
                            }else if(listMap[code].match(/自治旗$/)){
                                county6++;
                            }else if(listMap[code].match(/旗$/)){
                                county5++;
                            }
                        }
                    }
                    $module.find('.city1').text(city1);
                    $module.find('.city2').text(city2);
                    $module.find('.city3').text(city3);
                    $module.find('.city4').text(city4);

                    $module.find('.county1').text(county1);
                    $module.find('.county2').text(county2);
                    $module.find('.county3').text(county3);
                    $module.find('.county4').text(county4);
                    $module.find('.county5').text(county5);
                    $module.find('.county6').text(county6);
                    $module.find('.county7').text(county7);
                    $module.find('.county8').text(county8);

                    var searchItem = new locationSearch(map);
                    $location = $('.mod-panel input[name="location"]').suggestion({
                        dynamic:false,
                        autoSubmit:false,
                        onCallback:function(){
                            var location = $location.val();
                            if(location){
                                result = searchItem.query(location);
                                if(result.length>10){
                                    result = 10;
                                }
                                return result;
                            }
                            return [];
                        }
                    });
                });

                // 行政区划历史查询
                $.getJSON('https://passer-by.com/data_location/history.json',function(map){
                    historyMap = map;
                    $.getJSON('https://passer-by.com/data_location/diff.json',function(map){
                        diffMap = map;
                        for(var code in diffMap){
                            diffMap[code].forEach(function(value){
                                if(typeof diffMap2[value]=='undefined'){
                                    diffMap2[value] = [];
                                }
                                diffMap2[value].push(code);
                            });
                        }

                        var $location = $('#location');
                        $location.citys({
                            'code':'110101',
                            'onChange':function(data){
                                var code = data['code'].toString();
                                $location.find('.result-container').html(`
                                    <div class="table-inner">
                                        <table>
                                            <caption>当前行政区划</caption>
                                            <thead>
                                                <tr>
                                                    <th width="30%">区划代码</th>
                                                    <th>行政区划地址</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <tr>
                                                    <td>${code}</td>
                                                    <td>${getName(code)}</td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="table-inner">
                                        <table>
                                            <caption>历史行政区划</caption>
                                            <thead>
                                                <tr>
                                                    <th width="30%">区划代码</th>
                                                    <th>行政区划地址</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                ${
                                                    diffMap2[code]?
                                                    diffMap2[code].map(function(value){
                                                        return '<tr><td>'+value+'</td><td>'+getName(value)+'</td></tr>';
                                                    }).join(''):
                                                    '<tr><td colspan="2" align="center">暂无数据</td></tr>'
                                                }
                                            </tbody>
                                        </table>
                                    </div>
                                `);
                            }
                        });

                        var $idcard = $('#idcard');
                        $idcard.find('form').on('submit',function(){
                            var $this = $(this);
                            var id = $this.find('input[name="id"]').val();
                            var result = idcard(id);
                            if(!result){
                                alert('身份证号码格式错误！');
                            }else{
                                var newAddress = '';
                                var code = id.match(/^\d{6}/)[0];
                                if(diffMap[code]){
                                    newAddress = `<tr>
                                        <td class="th"><span>现所属地</span></td>
                                        <td>${diffMap[code].map(function(value){return '<p>'+getName(value)+'</p>';})}</td>
                                    </tr>`;
                                }
                                $idcard.find('.result-container').html(`
                                    <div class="table-inner">
                                        <table>
                                            <tbody>
                                                <tr><td class="th" width="25%">证件类型</td><td>${result['type']}</td></tr>
                                                <tr><td class="th">国籍</td><td>${result['country']}</td></tr>
                                                <tr><td class="th">首次签发地</td><td>${result['sign']}</td></tr>
                                                ${newAddress}
                                                <tr><td class="th">出生日期</td><td>${result['birthday'].replace(/(\d{4})(\d{2})(\d{2})/,'$1年$2月$3日')}</td></tr>
                                                <tr><td class="th">性别</td><td>${result['sex']}</td></tr>
                                                <tr><td class="th">有效性</td><td>${(result['isValid']?'<span class="text-green">有效</span>':'<span class="text-red">无效</span>')}</td></tr>
                                            </tbody>
                                        </table>
                                    </div>
                                `);
                            }
                            return false;
                        });
                    });
                });
            })();
        </script>
        <script async defer src="https://cdn.bootcdn.net/ajax/libs/github-buttons/2.21.1/buttons.min.js"></script>
        <script type="text/javascript" src="https://passer-by.com/static/script/common.js"></script>
        <script type="text/javascript" src="https://passer-by.com/static/script/stat.js"></script>
    </body>
</html>
